Skip to content

Commit cacab0c

Browse files
committed
Merge branch 'jk/rev-input-given-fix'
Feeding "$ZERO_OID" to "git log --ignore-missing --stdin", and running "git log --ignore-missing $ZERO_OID" fell back to start digging from HEAD; it has been corrected to become a no-op, like "git log --tags=no-tag-matches-this-pattern" does. * jk/rev-input-given-fix: revision: set rev_input_given in handle_revision_arg()
2 parents e9bd00a + 04a0e98 commit cacab0c

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

revision.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ static int handle_dotdot(const char *arg,
20172017
return ret;
20182018
}
20192019

2020-
int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsigned revarg_opt)
2020+
static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int flags, unsigned revarg_opt)
20212021
{
20222022
struct object_context oc;
20232023
char *mark;
@@ -2092,6 +2092,14 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
20922092
return 0;
20932093
}
20942094

2095+
int handle_revision_arg(const char *arg, struct rev_info *revs, int flags, unsigned revarg_opt)
2096+
{
2097+
int ret = handle_revision_arg_1(arg, revs, flags, revarg_opt);
2098+
if (!ret)
2099+
revs->rev_input_given = 1;
2100+
return ret;
2101+
}
2102+
20952103
static void read_pathspec_from_stdin(struct strbuf *sb,
20962104
struct strvec *prune)
20972105
{
@@ -2703,7 +2711,7 @@ static void NORETURN diagnose_missing_default(const char *def)
27032711
*/
27042712
int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
27052713
{
2706-
int i, flags, left, seen_dashdash, got_rev_arg = 0, revarg_opt;
2714+
int i, flags, left, seen_dashdash, revarg_opt;
27072715
struct strvec prune_data = STRVEC_INIT;
27082716
const char *submodule = NULL;
27092717
int seen_end_of_options = 0;
@@ -2792,8 +2800,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
27922800
strvec_pushv(&prune_data, argv + i);
27932801
break;
27942802
}
2795-
else
2796-
got_rev_arg = 1;
27972803
}
27982804

27992805
if (prune_data.nr) {
@@ -2822,7 +2828,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
28222828
opt->tweak(revs, opt);
28232829
if (revs->show_merge)
28242830
prepare_show_merge(revs);
2825-
if (revs->def && !revs->pending.nr && !revs->rev_input_given && !got_rev_arg) {
2831+
if (revs->def && !revs->pending.nr && !revs->rev_input_given) {
28262832
struct object_id oid;
28272833
struct object *object;
28282834
struct object_context oc;

t/t4202-log.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,16 @@ test_expect_success 'log does not default to HEAD when rev input is given' '
18501850
test_must_be_empty actual
18511851
'
18521852

1853+
test_expect_success 'do not default to HEAD with ignored object on cmdline' '
1854+
git log --ignore-missing $ZERO_OID >actual &&
1855+
test_must_be_empty actual
1856+
'
1857+
1858+
test_expect_success 'do not default to HEAD with ignored object on stdin' '
1859+
echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
1860+
test_must_be_empty actual
1861+
'
1862+
18531863
test_expect_success 'set up --source tests' '
18541864
git checkout --orphan source-a &&
18551865
test_commit one &&

t/t6018-rev-list-glob.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ test_expect_success 'rev-list should succeed with empty output with empty glob'
345345
test_must_be_empty actual
346346
'
347347

348+
test_expect_success 'rev-list should succeed with empty output when ignoring missing' '
349+
git rev-list --ignore-missing $ZERO_OID >actual &&
350+
test_must_be_empty actual
351+
'
352+
348353
test_expect_success 'shortlog accepts --glob/--tags/--remotes' '
349354
350355
compare shortlog "subspace/one subspace/two" --branches=subspace &&

0 commit comments

Comments
 (0)