free(prune);
}
-static int dotdot_missing(const char *arg, char *dotdot,
+static int dotdot_missing(const char *full_name,
struct rev_info *revs, int symmetric)
{
if (revs->ignore_missing)
return 0;
- /* de-munge so we report the full argument */
- *dotdot = '.';
die(symmetric
? "Invalid symmetric difference expression %s"
- : "Invalid revision range %s", arg);
+ : "Invalid revision range %s", full_name);
}
-static int handle_dotdot_1(const char *arg, char *dotdot,
+static int handle_dotdot_1(const char *a_name, const char *b_name,
+ const char *full_name, int symmetric,
struct rev_info *revs, int flags,
int cant_be_filename,
struct object_context *a_oc,
struct object_context *b_oc)
{
- const char *a_name, *b_name;
struct object_id a_oid, b_oid;
struct object *a_obj, *b_obj;
unsigned int a_flags, b_flags;
- int symmetric = 0;
unsigned int flags_exclude = flags ^ (UNINTERESTING | BOTTOM);
unsigned int oc_flags = GET_OID_COMMITTISH | GET_OID_RECORD_PATH;
- a_name = arg;
if (!*a_name)
a_name = "HEAD";
- b_name = dotdot + 2;
- if (*b_name == '.') {
- symmetric = 1;
- b_name++;
- }
if (!*b_name)
b_name = "HEAD";
return -1;
if (!cant_be_filename) {
- *dotdot = '.';
- verify_non_filename(revs->prefix, arg);
- *dotdot = '\0';
+ verify_non_filename(revs->prefix, full_name);
}
a_obj = parse_object(revs->repo, &a_oid);
b_obj = parse_object(revs->repo, &b_oid);
if (!a_obj || !b_obj)
- return dotdot_missing(arg, dotdot, revs, symmetric);
+ return dotdot_missing(full_name, revs, symmetric);
if (!symmetric) {
/* just A..B */
a = lookup_commit_reference(revs->repo, &a_obj->oid);
b = lookup_commit_reference(revs->repo, &b_obj->oid);
if (!a || !b)
- return dotdot_missing(arg, dotdot, revs, symmetric);
+ return dotdot_missing(full_name, revs, symmetric);
if (repo_get_merge_bases(the_repository, a, b, &exclude) < 0) {
commit_list_free(exclude);
int cant_be_filename)
{
struct object_context a_oc = {0}, b_oc = {0};
- char *dotdot = strstr(arg, "..");
+ const char *dotdot = strstr(arg, "..");
+ char *tmp;
+ int symmetric = 0;
int ret;
if (!dotdot)
return -1;
- *dotdot = '\0';
- ret = handle_dotdot_1(arg, dotdot, revs, flags, cant_be_filename,
- &a_oc, &b_oc);
- *dotdot = '.';
+ tmp = xmemdupz(arg, dotdot - arg);
+ dotdot += 2;
+ if (*dotdot == '.') {
+ symmetric = 1;
+ dotdot++;
+ }
+ ret = handle_dotdot_1(tmp, dotdot, arg, symmetric, revs, flags,
+ cant_be_filename, &a_oc, &b_oc);
+ free(tmp);
object_context_release(&a_oc);
object_context_release(&b_oc);