]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/add-ignore-errors-bit-assignment-fix'
authorJunio C Hamano <gitster@pobox.com>
Tue, 5 Feb 2019 22:26:13 +0000 (14:26 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Feb 2019 22:26:13 +0000 (14:26 -0800)
"git add --ignore-errors" did not work as advertised and instead
worked as an unintended synonym for "git add --renormalize", which
has been fixed.

* jk/add-ignore-errors-bit-assignment-fix:
  add: use separate ADD_CACHE_RENORMALIZE flag

builtin/add.c
cache.h
read-cache.c
t/t0025-crlf-renormalize.sh

index d461ba08b9b2663b4cadd9a1cb756523ffe8eb1f..7c2a7c5a4d4aa619e81ef61a69b619b7c96b8ac5 100644 (file)
@@ -137,7 +137,7 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
                        continue; /* do not touch non blobs */
                if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL))
                        continue;
-               retval |= add_file_to_cache(ce->name, flags | HASH_RENORMALIZE);
+               retval |= add_file_to_cache(ce->name, flags | ADD_CACHE_RENORMALIZE);
        }
 
        return retval;
diff --git a/cache.h b/cache.h
index 009e8b3b150eaab7c5c3705c0d466773743dbe0f..038e3764a9430e1f90b6b0ebbe0269197eb3e25b 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -755,6 +755,7 @@ extern int index_name_pos(const struct index_state *, const char *name, int name
 #define ADD_CACHE_JUST_APPEND 8                /* Append only; tree.c::read_tree() */
 #define ADD_CACHE_NEW_ONLY 16          /* Do not replace existing ones */
 #define ADD_CACHE_KEEP_CACHE_TREE 32   /* Do not invalidate cache-tree */
+#define ADD_CACHE_RENORMALIZE 64        /* Pass along HASH_RENORMALIZE */
 extern int add_index_entry(struct index_state *, struct cache_entry *ce, int option);
 extern void rename_index_entry_at(struct index_state *, int pos, const char *new_name);
 
index bfff271a3db92cfaaa93d23c5bf52297dda0419e..9783c493a321046e80a36847d8c36d1af6d263e3 100644 (file)
@@ -703,10 +703,10 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
        int intent_only = flags & ADD_CACHE_INTENT;
        int add_option = (ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE|
                          (intent_only ? ADD_CACHE_NEW_ONLY : 0));
-       int newflags = HASH_WRITE_OBJECT;
+       int hash_flags = HASH_WRITE_OBJECT;
 
-       if (flags & HASH_RENORMALIZE)
-               newflags |= HASH_RENORMALIZE;
+       if (flags & ADD_CACHE_RENORMALIZE)
+               hash_flags |= HASH_RENORMALIZE;
 
        if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode))
                return error(_("%s: can only add regular files, symbolic links or git-directories"), path);
@@ -762,7 +762,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
                }
        }
        if (!intent_only) {
-               if (index_path(istate, &ce->oid, path, st, newflags)) {
+               if (index_path(istate, &ce->oid, path, st, hash_flags)) {
                        discard_cache_entry(ce);
                        return error(_("unable to index file '%s'"), path);
                }
index 9d9e02a21112197a2a57a2877db24951d41a2996..e13363ade5cf500e6f57677eb961c5ca01197a12 100755 (executable)
@@ -27,4 +27,13 @@ test_expect_success 'renormalize CRLF in repo' '
        test_cmp expect actual
 '
 
+test_expect_success 'ignore-errors not mistaken for renormalize' '
+       git reset --hard &&
+       echo "*.txt text=auto" >.gitattributes &&
+       git ls-files --eol >expect &&
+       git add --ignore-errors "*.txt" &&
+       git ls-files --eol >actual &&
+       test_cmp expect actual
+'
+
 test_done