Skip to content

Commit

Permalink
Merge branch 'nd/magic-pathspec'
Browse files Browse the repository at this point in the history
All callers to parse_pathspec() must choose between getting no
pathspec or one path that is limited to the current directory
when there is no paths given on the command line, but there were
two callers that violated this rule, triggering a BUG().

* nd/magic-pathspec:
  Fix calling parse_pathspec with no paths nor PATHSPEC_PREFER_* flags
  • Loading branch information
gitster committed Oct 30, 2013
2 parents 414b703 + c8556c6 commit 4cebbe6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion line-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ void line_log_init(struct rev_info *rev, const char *prefix, struct string_list
r = r->next;
}
paths[count] = NULL;
parse_pathspec(&rev->diffopt.pathspec, 0, 0, "", paths);
parse_pathspec(&rev->diffopt.pathspec, 0,
PATHSPEC_PREFER_FULL, "", paths);
free(paths);
}
}
Expand Down
3 changes: 2 additions & 1 deletion revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,8 @@ static void prepare_show_merge(struct rev_info *revs)
i++;
}
free_pathspec(&revs->prune_data);
parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC, 0, "", prune);
parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC,
PATHSPEC_PREFER_FULL, "", prune);
revs->limited = 1;
}

Expand Down
15 changes: 15 additions & 0 deletions t/t4208-log-magic-pathspec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,19 @@ test_expect_success 'git log HEAD -- :/' '
test_cmp expected actual
'

test_expect_success 'command line pathspec parsing for "git log"' '
git reset --hard &&
>a &&
git add a &&
git commit -m "add an empty a" --allow-empty &&
echo 1 >a &&
git commit -a -m "update a to 1" &&
git checkout HEAD^ &&
echo 2 >a &&
git commit -a -m "update a to 2" &&
test_must_fail git merge master &&
git add a &&
git log --merge -- a
'

test_done

0 comments on commit 4cebbe6

Please sign in to comment.