Skip to content

Commit 6ffb5fc

Browse files
committed
Merge branch 'rs/add-dry-run-without-objects'
Stop "git add --dry-run" from creating new blob and tree objects. * rs/add-dry-run-without-objects: add: don't write objects with --dry-run
2 parents 525705a + e578d03 commit 6ffb5fc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

read-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
738738
int intent_only = flags & ADD_CACHE_INTENT;
739739
int add_option = (ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE|
740740
(intent_only ? ADD_CACHE_NEW_ONLY : 0));
741-
int hash_flags = HASH_WRITE_OBJECT;
741+
unsigned hash_flags = pretend ? 0 : HASH_WRITE_OBJECT;
742742
struct object_id oid;
743743

744744
if (flags & ADD_CACHE_RENORMALIZE)

t/t2200-add-update.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,15 @@ test_expect_success 'add -n -u should not add but just report' '
129129
echo "remove '\''top'\''"
130130
) >expect &&
131131
before=$(git ls-files -s check top) &&
132+
git count-objects -v >objects_before &&
132133
echo changed >>check &&
133134
rm -f top &&
134135
git add -n -u >actual &&
135136
after=$(git ls-files -s check top) &&
137+
git count-objects -v >objects_after &&
136138
137139
test "$before" = "$after" &&
140+
test_cmp objects_before objects_after &&
138141
test_cmp expect actual
139142
140143
'

0 commit comments

Comments
 (0)