OSDN Git Service

submodule.c: factor out early loop termination in is_submodule_modified
authorStefan Beller <sbeller@google.com>
Sat, 25 Mar 2017 00:36:05 +0000 (17:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Mar 2017 16:48:19 +0000 (09:48 -0700)
This makes it easier for a follow up patch.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
submodule.c

index 2c667ac..93e3fef 100644 (file)
@@ -1075,16 +1075,16 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)
        len = strbuf_read(&buf, cp.out, 1024);
        line = buf.buf;
        while (len > 2) {
-               if ((line[0] == '?') && (line[1] == '?')) {
+               if ((line[0] == '?') && (line[1] == '?'))
                        dirty_submodule |= DIRTY_SUBMODULE_UNTRACKED;
-                       if (dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
-                               break;
-               } else {
+               else
                        dirty_submodule |= DIRTY_SUBMODULE_MODIFIED;
-                       if (ignore_untracked ||
-                           (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED))
-                               break;
-               }
+
+               if ((dirty_submodule & DIRTY_SUBMODULE_MODIFIED) &&
+                   ((dirty_submodule & DIRTY_SUBMODULE_UNTRACKED) ||
+                    ignore_untracked))
+                       break;
+
                next_line = strchr(line, '\n');
                if (!next_line)
                        break;