Skip to content

Commit 4cebbe6

Browse files
committed
Merge branch 'nd/magic-pathspec'
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
2 parents 414b703 + c8556c6 commit 4cebbe6

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

line-log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,8 @@ void line_log_init(struct rev_info *rev, const char *prefix, struct string_list
760760
r = r->next;
761761
}
762762
paths[count] = NULL;
763-
parse_pathspec(&rev->diffopt.pathspec, 0, 0, "", paths);
763+
parse_pathspec(&rev->diffopt.pathspec, 0,
764+
PATHSPEC_PREFER_FULL, "", paths);
764765
free(paths);
765766
}
766767
}

revision.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,8 @@ static void prepare_show_merge(struct rev_info *revs)
13721372
i++;
13731373
}
13741374
free_pathspec(&revs->prune_data);
1375-
parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC, 0, "", prune);
1375+
parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC,
1376+
PATHSPEC_PREFER_FULL, "", prune);
13761377
revs->limited = 1;
13771378
}
13781379

t/t4208-log-magic-pathspec.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,19 @@ test_expect_success 'git log HEAD -- :/' '
4646
test_cmp expected actual
4747
'
4848

49+
test_expect_success 'command line pathspec parsing for "git log"' '
50+
git reset --hard &&
51+
>a &&
52+
git add a &&
53+
git commit -m "add an empty a" --allow-empty &&
54+
echo 1 >a &&
55+
git commit -a -m "update a to 1" &&
56+
git checkout HEAD^ &&
57+
echo 2 >a &&
58+
git commit -a -m "update a to 2" &&
59+
test_must_fail git merge master &&
60+
git add a &&
61+
git log --merge -- a
62+
'
63+
4964
test_done

0 commit comments

Comments
 (0)