Commits

Anonymous committed 2fe167b

git-gui: Ensure .git/info/exclude is honored in Cygwin workdirs

If we are using Cygwin and the git repository is actually a
workdir (by way of git-new-workdir) but this Tcl process is
a native Tcl/Tk and not the Cygwin Tcl/Tk then we are unable
to traverse the .git/info path as it is a Cygwin symlink and
not a standard Windows directory.

So we actually need to start a Cygwin process that can do the
path translation for us and let it test for .git/info/exclude
so we know if we can include that file in our git-ls-files or
not.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

  • Participants
  • Parent commits 299077f

Comments (0)

Files changed (1)

 	}
 }
 
+if {[is_Cygwin]} {
+	set is_git_info_link {}
+	set is_git_info_exclude {}
+	proc have_info_exclude {} {
+		global is_git_info_link is_git_info_exclude
+
+		if {$is_git_info_link eq {}} {
+			set is_git_info_link [file isfile [gitdir info.lnk]]
+		}
+
+		if {$is_git_info_link} {
+			if {$is_git_info_exclude eq {}} {
+				if {[catch {exec test -f [gitdir info exclude]}]} {
+					set is_git_info_exclude 0
+				} else {
+					set is_git_info_exclude 1
+				}
+			}
+			return $is_git_info_exclude
+		} else {
+			return [file readable [gitdir info exclude]]
+		}
+	}
+} else {
+	proc have_info_exclude {} {
+		return [file readable [gitdir info exclude]]
+	}
+}
+
 proc rescan_stage2 {fd after} {
 	global rescan_active buf_rdi buf_rdf buf_rlo
 
 	}
 
 	set ls_others [list --exclude-per-directory=.gitignore]
-	set info_exclude [gitdir info exclude]
-	if {[file readable $info_exclude]} {
-		lappend ls_others "--exclude-from=$info_exclude"
+	if {[have_info_exclude]} {
+		lappend ls_others "--exclude-from=[gitdir info exclude]"
 	}
 	set user_exclude [get_config core.excludesfile]
 	if {$user_exclude ne {} && [file readable $user_exclude]} {