Skip to content

Commit 3aa99df

Browse files
peffgitster
authored andcommitted
fast-import: clarify "inline" logic in file_change_m
When we read a fast-import line like: M 100644 :1 foo.c we point the local object_entry variable "oe" to the object named by the mark ":1". When the input uses the "inline" construct, however, we do not have such an object_entry. The current code is careful not to access "oe" in the inline case, but we can make the assumption even more obvious (and catch violations of it) by setting oe to NULL and adding a comment. As a bonus, this also squelches an over-zealous gcc -Wuninitialized warning, which means we can drop the "oe = oe" initialization hack. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 25043d8 commit 3aa99df

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fast-import.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,7 @@ static void file_change_m(struct branch *b)
22652265
const char *p = command_buf.buf + 2;
22662266
static struct strbuf uq = STRBUF_INIT;
22672267
const char *endp;
2268-
struct object_entry *oe = oe;
2268+
struct object_entry *oe;
22692269
unsigned char sha1[20];
22702270
uint16_t mode, inline_data = 0;
22712271

@@ -2292,6 +2292,7 @@ static void file_change_m(struct branch *b)
22922292
hashcpy(sha1, oe->idx.sha1);
22932293
} else if (!prefixcmp(p, "inline ")) {
22942294
inline_data = 1;
2295+
oe = NULL; /* not used with inline_data, but makes gcc happy */
22952296
p += strlen("inline"); /* advance to space */
22962297
} else {
22972298
if (get_sha1_hex(p, sha1))

0 commit comments

Comments
 (0)