--- OLD/builtin-checkout-index.c Thu Jan 1 00:00:00 1970 +++ NEW/builtin-checkout-index.c Thu Jan 1 00:00:00 1970 @@ -46,11 +46,12 @@ static int line_termination = '\n'; static int checkout_stage; /* default to checkout stage0 */ static int to_tempfile; +static int tempfile_mode; static char topath[4][PATH_MAX + 1]; static struct checkout state; -static void write_tempfile_record(const char *name, int prefix_length) +static void write_tempfile_record(const char *name, unsigned int mode, int prefix_length) { int i; @@ -67,6 +68,10 @@ fputs(topath[checkout_stage], stdout); putchar('\t'); + + if (tempfile_mode) + printf("%03o\t",mode&0777); + write_name_quoted(name + prefix_length, stdout, line_termination); for (i = 0; i < 4; i++) { @@ -81,6 +86,7 @@ int has_same_name = 0; int did_checkout = 0; int errs = 0; + int mode = 0; if (pos < 0) pos = -pos - 1; @@ -96,6 +102,7 @@ && (CHECKOUT_ALL != checkout_stage || !ce_stage(ce))) continue; did_checkout = 1; + mode = ce->ce_mode; if (checkout_entry(ce, &state, to_tempfile ? topath[ce_stage(ce)] : NULL) < 0) errs++; @@ -103,7 +110,7 @@ if (did_checkout) { if (to_tempfile) - write_tempfile_record(name, prefix_length); + write_tempfile_record(name, mode, prefix_length); return errs > 0 ? -1 : 0; } @@ -138,7 +145,7 @@ if (last_ce && to_tempfile) { if (ce_namelen(last_ce) != ce_namelen(ce) || memcmp(last_ce->name, ce->name, ce_namelen(ce))) - write_tempfile_record(last_ce->name, prefix_length); + write_tempfile_record(last_ce->name, last_ce->ce_mode, prefix_length); } if (checkout_entry(ce, &state, to_tempfile ? topath[ce_stage(ce)] : NULL) < 0) @@ -146,7 +153,7 @@ last_ce = ce; } if (last_ce && to_tempfile) - write_tempfile_record(last_ce->name, prefix_length); + write_tempfile_record(last_ce->name, last_ce->ce_mode, prefix_length); if (errs) /* we have already done our error reporting. * exit with the same code as die(). @@ -232,6 +239,8 @@ "read list of paths from the standard input"), OPT_BOOLEAN(0, "temp", &to_tempfile, "write the content to temporary files"), + OPT_BOOLEAN(0, "temp-mode", &tempfile_mode, + "report modes for content written to temporary files"), OPT_CALLBACK(0, "prefix", NULL, "string", "when creating files, prepend ", option_parse_prefix),