Merge branches 'jc/sha1', 'jc/diff' and 'jc/ws'

* jc/sha1:
  get_sha1_1: allow octopus^12 to be properly parsed.

* jc/diff:
  combine-diff: finishing touches to git-diff-tree --cc

* jc/ws:
  whitespace cleanup.
maint
Junio C Hamano 2006-02-03 23:52:20 -08:00
commit 2d310d8a01
3 changed files with 30 additions and 38 deletions

View File

@ -548,9 +548,9 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent)
if (!(sline[hunk_end].flag & mark)) if (!(sline[hunk_end].flag & mark))
break; break;
for (i = 0; i <= num_parent; i++) putchar(combine_marker); for (i = 0; i <= num_parent; i++) putchar(combine_marker);
printf(" +%lu,%lu ", lno+1, hunk_end-lno);
for (i = 0; i < num_parent; i++) for (i = 0; i < num_parent; i++)
show_parent_lno(sline, lno, hunk_end, cnt, i); show_parent_lno(sline, lno, hunk_end, cnt, i);
printf(" +%lu,%lu ", lno+1, hunk_end-lno);
for (i = 0; i <= num_parent; i++) putchar(combine_marker); for (i = 0; i <= num_parent; i++) putchar(combine_marker);
putchar('\n'); putchar('\n');
while (lno < hunk_end) { while (lno < hunk_end) {
@ -714,11 +714,11 @@ int show_combined_diff(struct combine_diff_path *elem, int num_parent,
printf("index "); printf("index ");
for (i = 0; i < num_parent; i++) { for (i = 0; i < num_parent; i++) {
printf("%s%s", printf("%s%s",
i ? ".." : "", i ? "," : "",
find_unique_abbrev(elem->parent_sha1[i], find_unique_abbrev(elem->parent_sha1[i],
DEFAULT_ABBREV)); DEFAULT_ABBREV));
} }
printf("->%s\n", printf("..%s\n",
find_unique_abbrev(elem->sha1, DEFAULT_ABBREV)); find_unique_abbrev(elem->sha1, DEFAULT_ABBREV));
dump_sline(sline, cnt, num_parent); dump_sline(sline, cnt, num_parent);
} }

View File

@ -220,7 +220,6 @@ static void start_object_request(struct object_request *obj_req)
free(obj_req->url); free(obj_req->url);
return; return;
} }
} }


static void finish_object_request(struct object_request *obj_req) static void finish_object_request(struct object_request *obj_req)

View File

@ -388,43 +388,36 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)


static int get_sha1_1(const char *name, int len, unsigned char *sha1) static int get_sha1_1(const char *name, int len, unsigned char *sha1)
{ {
int parent, ret; int ret, has_suffix;
const char *cp; const char *cp;


/* foo^[0-9] or foo^ (== foo^1); we do not do more than 9 parents. */
if (len > 2 && name[len-2] == '^' &&
name[len-1] >= '0' && name[len-1] <= '9') {
parent = name[len-1] - '0';
len -= 2;
}
else if (len > 1 && name[len-1] == '^') {
parent = 1;
len--;
} else
parent = -1;

if (parent >= 0)
return get_parent(name, len, sha1, parent);

/* "name~3" is "name^^^", /* "name~3" is "name^^^",
* "name~12" is "name^^^^^^^^^^^^", and
* "name~" and "name~0" are name -- not "name^0"! * "name~" and "name~0" are name -- not "name^0"!
* "name^" is not "name^0"; it is "name^1".
*/ */
parent = 0; has_suffix = 0;
for (cp = name + len - 1; name <= cp; cp--) { for (cp = name + len - 1; name <= cp; cp--) {
int ch = *cp; int ch = *cp;
if ('0' <= ch && ch <= '9') if ('0' <= ch && ch <= '9')
continue; continue;
if (ch != '~') if (ch == '~' || ch == '^')
parent = -1; has_suffix = ch;
break; break;
} }
if (!parent && *cp == '~') {
if (has_suffix) {
int num = 0;
int len1 = cp - name; int len1 = cp - name;
cp++; cp++;
while (cp < name + len) while (cp < name + len)
parent = parent * 10 + *cp++ - '0'; num = num * 10 + *cp++ - '0';
return get_nth_ancestor(name, len1, sha1, parent); if (has_suffix == '^') {
if (!num && len1 == len - 1)
num = 1;
return get_parent(name, len1, sha1, num);
}
/* else if (has_suffix == '~') -- goes without saying */
return get_nth_ancestor(name, len1, sha1, num);
} }


ret = peel_onion(name, len, sha1); ret = peel_onion(name, len, sha1);