mirror of
https://github.com/git/git
synced 2024-09-13 21:34:42 +00:00
Merge branch 'maint'
* maint: don't use default revision if a rev was specified for_each_recent_reflog_ent(): use strbuf, fix offset handling t/Makefile: remove test artifacts upon "make clean" blame: fix indent of line numbers
This commit is contained in:
commit
3a27f415df
|
@ -1772,7 +1772,7 @@ static int lineno_width(int lines)
|
||||||
{
|
{
|
||||||
int i, width;
|
int i, width;
|
||||||
|
|
||||||
for (width = 1, i = 10; i <= lines + 1; width++)
|
for (width = 1, i = 10; i <= lines; width++)
|
||||||
i *= 10;
|
i *= 10;
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
22
refs.c
22
refs.c
|
@ -1574,7 +1574,7 @@ int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs,
|
||||||
{
|
{
|
||||||
const char *logfile;
|
const char *logfile;
|
||||||
FILE *logfp;
|
FILE *logfp;
|
||||||
char buf[1024];
|
struct strbuf sb = STRBUF_INIT;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
logfile = git_path("logs/%s", ref);
|
logfile = git_path("logs/%s", ref);
|
||||||
|
@ -1587,24 +1587,24 @@ int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs,
|
||||||
if (fstat(fileno(logfp), &statbuf) ||
|
if (fstat(fileno(logfp), &statbuf) ||
|
||||||
statbuf.st_size < ofs ||
|
statbuf.st_size < ofs ||
|
||||||
fseek(logfp, -ofs, SEEK_END) ||
|
fseek(logfp, -ofs, SEEK_END) ||
|
||||||
fgets(buf, sizeof(buf), logfp)) {
|
strbuf_getwholeline(&sb, logfp, '\n')) {
|
||||||
fclose(logfp);
|
fclose(logfp);
|
||||||
|
strbuf_release(&sb);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(buf, sizeof(buf), logfp)) {
|
while (!strbuf_getwholeline(&sb, logfp, '\n')) {
|
||||||
unsigned char osha1[20], nsha1[20];
|
unsigned char osha1[20], nsha1[20];
|
||||||
char *email_end, *message;
|
char *email_end, *message;
|
||||||
unsigned long timestamp;
|
unsigned long timestamp;
|
||||||
int len, tz;
|
int tz;
|
||||||
|
|
||||||
/* old SP new SP name <email> SP time TAB msg LF */
|
/* old SP new SP name <email> SP time TAB msg LF */
|
||||||
len = strlen(buf);
|
if (sb.len < 83 || sb.buf[sb.len - 1] != '\n' ||
|
||||||
if (len < 83 || buf[len-1] != '\n' ||
|
get_sha1_hex(sb.buf, osha1) || sb.buf[40] != ' ' ||
|
||||||
get_sha1_hex(buf, osha1) || buf[40] != ' ' ||
|
get_sha1_hex(sb.buf + 41, nsha1) || sb.buf[81] != ' ' ||
|
||||||
get_sha1_hex(buf + 41, nsha1) || buf[81] != ' ' ||
|
!(email_end = strchr(sb.buf + 82, '>')) ||
|
||||||
!(email_end = strchr(buf + 82, '>')) ||
|
|
||||||
email_end[1] != ' ' ||
|
email_end[1] != ' ' ||
|
||||||
!(timestamp = strtoul(email_end + 2, &message, 10)) ||
|
!(timestamp = strtoul(email_end + 2, &message, 10)) ||
|
||||||
!message || message[0] != ' ' ||
|
!message || message[0] != ' ' ||
|
||||||
|
@ -1618,11 +1618,13 @@ int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs,
|
||||||
message += 6;
|
message += 6;
|
||||||
else
|
else
|
||||||
message += 7;
|
message += 7;
|
||||||
ret = fn(osha1, nsha1, buf+82, timestamp, tz, message, cb_data);
|
ret = fn(osha1, nsha1, sb.buf + 82, timestamp, tz, message,
|
||||||
|
cb_data);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fclose(logfp);
|
fclose(logfp);
|
||||||
|
strbuf_release(&sb);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1334,7 +1334,7 @@ static void append_prune_data(const char ***prune_data, const char **av)
|
||||||
*/
|
*/
|
||||||
int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
|
int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
|
||||||
{
|
{
|
||||||
int i, flags, left, seen_dashdash, read_from_stdin;
|
int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0;
|
||||||
const char **prune_data = NULL;
|
const char **prune_data = NULL;
|
||||||
|
|
||||||
/* First, search for "--" */
|
/* First, search for "--" */
|
||||||
|
@ -1460,6 +1460,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
|
||||||
append_prune_data(&prune_data, argv + i);
|
append_prune_data(&prune_data, argv + i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
got_rev_arg = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prune_data)
|
if (prune_data)
|
||||||
|
@ -1469,7 +1471,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
|
||||||
revs->def = def;
|
revs->def = def;
|
||||||
if (revs->show_merge)
|
if (revs->show_merge)
|
||||||
prepare_show_merge(revs);
|
prepare_show_merge(revs);
|
||||||
if (revs->def && !revs->pending.nr) {
|
if (revs->def && !revs->pending.nr && !got_rev_arg) {
|
||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
struct object *object;
|
struct object *object;
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
|
|
|
@ -27,6 +27,8 @@ pre-clean:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -r 'trash directory'.* test-results
|
$(RM) -r 'trash directory'.* test-results
|
||||||
|
$(RM) t????/cvsroot/CVSROOT/?*
|
||||||
|
$(RM) -r valgrind/bin
|
||||||
|
|
||||||
aggregate-results-and-cleanup: $(T)
|
aggregate-results-and-cleanup: $(T)
|
||||||
$(MAKE) aggregate-results
|
$(MAKE) aggregate-results
|
||||||
|
|
|
@ -64,4 +64,13 @@ test_expect_success 'using --date= shows reflog date (oneline)' '
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
: >expect
|
||||||
|
test_expect_success 'empty reflog file' '
|
||||||
|
git branch empty &&
|
||||||
|
: >.git/logs/refs/heads/empty &&
|
||||||
|
|
||||||
|
git log -g empty >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
|
@ -11,7 +11,15 @@ test_expect_success setup '
|
||||||
echo B B B B B >two &&
|
echo B B B B B >two &&
|
||||||
echo C C C C C >tres &&
|
echo C C C C C >tres &&
|
||||||
echo ABC >mouse &&
|
echo ABC >mouse &&
|
||||||
git add one two tres mouse &&
|
for i in 1 2 3 4 5 6 7 8 9
|
||||||
|
do
|
||||||
|
echo $i
|
||||||
|
done >nine_lines &&
|
||||||
|
for i in 1 2 3 4 5 6 7 8 9 a
|
||||||
|
do
|
||||||
|
echo $i
|
||||||
|
done >ten_lines &&
|
||||||
|
git add one two tres mouse nine_lines ten_lines &&
|
||||||
test_tick &&
|
test_tick &&
|
||||||
GIT_AUTHOR_NAME=Initial git commit -m Initial &&
|
GIT_AUTHOR_NAME=Initial git commit -m Initial &&
|
||||||
|
|
||||||
|
@ -167,4 +175,14 @@ test_expect_success 'blame -L with invalid end' '
|
||||||
grep "has only 2 lines" errors
|
grep "has only 2 lines" errors
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'indent of line numbers, nine lines' '
|
||||||
|
git blame nine_lines >actual &&
|
||||||
|
test $(grep -c " " actual) = 0
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'indent of line numbers, ten lines' '
|
||||||
|
git blame ten_lines >actual &&
|
||||||
|
test $(grep -c " " actual) = 9
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue