summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorThomas Gummerer <t.gummerer@gmail.com>2016-09-14 21:07:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-15 19:13:54 (GMT)
commit610d55af0f082f6b866dc858e144c03d8ed4424c (patch)
tree00ddc8f01e22cd000590b00952eede317562fb7b /read-cache.c
parentd9d7096662122f6b82ad6e4c08397b75906da78d (diff)
downloadgit-610d55af0f082f6b866dc858e144c03d8ed4424c.zip
git-610d55af0f082f6b866dc858e144c03d8ed4424c.tar.gz
git-610d55af0f082f6b866dc858e144c03d8ed4424c.tar.bz2
add: modify already added files when --chmod is given
When the chmod option was added to git add, it was hooked up to the diff machinery, meaning that it only works when the version in the index differs from the version on disk. As the option was supposed to mirror the chmod option in update-index, which always changes the mode in the index, regardless of the status of the file, make sure the option behaves the same way in git add. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/read-cache.c b/read-cache.c
index d11a43b..c2b2e97 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -630,7 +630,7 @@ void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
hashcpy(ce->sha1, sha1);
}
-int add_to_index(struct index_state *istate, const char *path, struct stat *st, int flags, int force_mode)
+int add_to_index(struct index_state *istate, const char *path, struct stat *st, int flags)
{
int size, namelen, was_same;
mode_t st_mode = st->st_mode;
@@ -659,11 +659,10 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
else
ce->ce_flags |= CE_INTENT_TO_ADD;
- if (S_ISREG(st_mode) && force_mode)
- ce->ce_mode = create_ce_mode(force_mode);
- else if (trust_executable_bit && has_symlinks)
+
+ if (trust_executable_bit && has_symlinks) {
ce->ce_mode = create_ce_mode(st_mode);
- else {
+ } else {
/* If there is an existing entry, pick the mode bits and type
* from it, otherwise assume unexecutable regular file.
*/
@@ -722,13 +721,12 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
return 0;
}
-int add_file_to_index(struct index_state *istate, const char *path,
- int flags, int force_mode)
+int add_file_to_index(struct index_state *istate, const char *path, int flags)
{
struct stat st;
if (lstat(path, &st))
die_errno("unable to stat '%s'", path);
- return add_to_index(istate, path, &st, flags, force_mode);
+ return add_to_index(istate, path, &st, flags);
}
struct cache_entry *make_cache_entry(unsigned int mode,