From: Jonas Fonseca Date: Tue, 30 Sep 2008 14:57:28 +0000 (+0200) Subject: Cleanup exclude rule setup by using ls-files --exclude-standard flag X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=33623c0022b49a5f2774b37a58726a95a4367447;p=tig.git Cleanup exclude rule setup by using ls-files --exclude-standard flag This makes user specific ignore rules effective in the status view. --- diff --git a/NEWS b/NEWS index 3699097..85faaf2 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,11 @@ Improvements: - Main: use --topo-order also when rev-list arguments are given on the command line. +Bug fixes: + + - Status: use ls-files' --exclude-standard so user specific ignore + rules are effective. The option was added in git version 1.5.4. + tig-0.12 -------- diff --git a/tig.c b/tig.c index 26cd2ef..15a42a4 100644 --- a/tig.c +++ b/tig.c @@ -3967,9 +3967,9 @@ error_out: #define STATUS_DIFF_INDEX_CMD "git diff-index -z --diff-filter=ACDMRTXB --cached -M HEAD" #define STATUS_DIFF_FILES_CMD "git diff-files -z" #define STATUS_LIST_OTHER_CMD \ - "git ls-files -z --others --exclude-per-directory=.gitignore" + "git ls-files -z --others --exclude-standard" #define STATUS_LIST_NO_HEAD_CMD \ - "git ls-files -z --cached --exclude-per-directory=.gitignore" + "git ls-files -z --cached --exclude-standard" #define STATUS_DIFF_INDEX_SHOW_CMD \ "git diff-index --root --patch-with-stat -C -M --cached HEAD -- %s %s 2>/dev/null" @@ -3986,12 +3986,7 @@ error_out: static bool status_open(struct view *view) { - struct stat statbuf; - char exclude[SIZEOF_STR]; - char indexcmd[SIZEOF_STR] = STATUS_DIFF_INDEX_CMD; - char othercmd[SIZEOF_STR] = STATUS_LIST_OTHER_CMD; unsigned long prev_lineno = view->lineno; - char indexstatus = 0; size_t i; for (i = 0; i < view->lines; i++) @@ -4011,33 +4006,16 @@ status_open(struct view *view) else if (!string_format(status_onbranch, "On branch %s", opt_head)) return FALSE; - if (opt_no_head) { - string_copy(indexcmd, STATUS_LIST_NO_HEAD_CMD); - indexstatus = 'A'; - } + system("git update-index -q --refresh >/dev/null 2>/dev/null"); - if (!string_format(exclude, "%s/info/exclude", opt_git_dir)) + if (opt_no_head && + !status_run(view, STATUS_LIST_NO_HEAD_CMD, 'A', LINE_STAT_STAGED)) + return FALSE; + else if (!status_run(view, STATUS_DIFF_INDEX_CMD, 0, LINE_STAT_STAGED)) return FALSE; - if (stat(exclude, &statbuf) >= 0) { - size_t cmdsize = strlen(othercmd); - - if (!string_format_from(othercmd, &cmdsize, " %s", "--exclude-from=") || - sq_quote(othercmd, cmdsize, exclude) >= sizeof(othercmd)) - return FALSE; - - cmdsize = strlen(indexcmd); - if (opt_no_head && - (!string_format_from(indexcmd, &cmdsize, " %s", "--exclude-from=") || - sq_quote(indexcmd, cmdsize, exclude) >= sizeof(indexcmd))) - return FALSE; - } - - system("git update-index -q --refresh >/dev/null 2>/dev/null"); - - if (!status_run(view, indexcmd, indexstatus, LINE_STAT_STAGED) || - !status_run(view, STATUS_DIFF_FILES_CMD, 0, LINE_STAT_UNSTAGED) || - !status_run(view, othercmd, '?', LINE_STAT_UNTRACKED)) + if (!status_run(view, STATUS_DIFF_FILES_CMD, 0, LINE_STAT_UNSTAGED) || + !status_run(view, STATUS_LIST_OTHER_CMD, '?', LINE_STAT_UNTRACKED)) return FALSE; /* If all went well restore the previous line number to stay in