• Bug#1108983: git: diff for NMU version 1:2.50.1-0.1 (2/4)

    From Adrian Bunk@21:1/5 to All on Wed Jul 30 01:10:01 2025
    [continued from previous message]

    + foreach line [split $buf "\0"] {
    + if {[regexp {^([^\n]+)\n(.*)$} $line line name value]} {
    + if {[is_many_config $name]} {
    + lappend arr($name) $value
    + } else {
    + set arr($name) $value
    }
    - close $fd_rc
    + } elseif {[regexp {^([^\n]+)$} $line line name]} {
    + # no value given, but interpreting them as
    + # boolean will be handled as true
    + set arr($name) {}
    }
    }
    }
    @@ -1427,7 +1450,7 @@
    set merge_head [gitdir MERGE_HEAD]
    if {[file exists $merge_head]} {
    set ct merge
    - set fd_mh [open $merge_head r]
    + set fd_mh [safe_open_file $merge_head r]
    while {[gets $fd_mh line] >= 0} {
    lappend mh $line
    }
    @@ -1446,7 +1469,7 @@
    return $p
    }
    if {$empty_tree eq {}} {
    - set empty_tree [git mktree << {}]
    + set empty_tree [git_redir [list mktree] [list << {}]]
    }
    return $empty_tree
    }
    @@ -1505,12 +1528,12 @@
    } else {
    set rescan_active 1
    ui_status [mc "Refreshing file status..."]
    - set fd_rf [git_read update-index \
    + set fd_rf [git_read [list update-index \
    -q \
    --unmerged \
    --ignore-missing \
    --refresh \
    - ]
    + ]]
    fconfigure $fd_rf -blocking 0 -translation binary
    fileevent $fd_rf readable \
    [list rescan_stage2 $fd_rf $after]
    @@ -1550,11 +1573,11 @@
    set rescan_active 2
    ui_status [mc "Scanning for modified files ..."]
    if {[git-version >= "1.7.2"]} {
    - set fd_di [git_read diff-index --cached --ignore-submodules=dirty -z [PARENT]]
    + set fd_di [git_read [list diff-index --cached --ignore-submodules=dirty -z [PARENT]]]
    } else {
    - set fd_di [git_read diff-index --cached -z [PARENT]]
    + set fd_di [git_read [list diff-index --cached -z [PARENT]]]
    }
    - set fd_df [git_read diff-files -z]
    + set fd_df [git_read [list diff-files -z]]

    fconfigure $fd_di -blocking 0 -translation binary -encoding binary
    fconfigure $fd_df -blocking 0 -translation binary -encoding binary
    @@ -1563,7 +1586,7 @@
    fileevent $fd_df readable [list read_diff_files $fd_df $after]

    if {[is_config_true gui.displayuntracked]} {
    - set fd_lo [eval git_read ls-files --others -z $ls_others]
    + set fd_lo [git_read [concat ls-files --others -z $ls_others]]
    fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
    fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
    incr rescan_active
    @@ -1575,7 +1598,7 @@

    set f [gitdir $file]
    if {[file isfile $f]} {
    - if {[catch {set fd [open $f r]}]} {
    + if {[catch {set fd [safe_open_file $f r]}]} {
    return 0
    }
    fconfigure $fd -eofchar {}
    @@ -1599,23 +1622,23 @@
    # it will be .git/MERGE_MSG (merge), .git/SQUASH_MSG (squash), or an
    # empty file but existent file.

    - set fd_pcm [open [gitdir PREPARE_COMMIT_MSG] a]
    + set fd_pcm [safe_open_file [gitdir PREPARE_COMMIT_MSG] a]

    if {[file isfile [gitdir MERGE_MSG]]} {
    set pcm_source "merge"
    - set fd_mm [open [gitdir MERGE_MSG] r]
    + set fd_mm [safe_open_file [gitdir MERGE_MSG] r]
    fconfigure $fd_mm -encoding utf-8
    puts -nonewline $fd_pcm [read $fd_mm]
    close $fd_mm
    } elseif {[file isfile [gitdir SQUASH_MSG]]} {
    set pcm_source "squash"
    - set fd_sm [open [gitdir SQUASH_MSG] r]
    + set fd_sm [safe_open_file [gitdir SQUASH_MSG] r]
    fconfigure $fd_sm -encoding utf-8
    puts -nonewline $fd_pcm [read $fd_sm]
    close $fd_sm
    } elseif {[file isfile [get_config commit.template]]} {
    set pcm_source "template"
    - set fd_sm [open [get_config commit.template] r]
    + set fd_sm [safe_open_file [get_config commit.template] r]
    fconfigure $fd_sm -encoding utf-8
    puts -nonewline $fd_pcm [read $fd_sm]
    close $fd_sm
    @@ -2205,7 +2228,7 @@
    unset env(GIT_DIR)
    unset env(GIT_WORK_TREE)
    }
    - eval exec $cmd $revs "--" "--" &
    + safe_exec_bg [concat $cmd $revs "--" "--"]

    set env(GIT_DIR) $_gitdir
    set env(GIT_WORK_TREE) $_gitworktree
    @@ -2242,7 +2265,7 @@
    set pwd [pwd]
    cd $current_diff_path

    - eval exec $exe gui &
    + safe_exec_bg [concat $exe gui]

    set env(GIT_DIR) $_gitdir
    set env(GIT_WORK_TREE) $_gitworktree
    @@ -2273,16 +2296,18 @@

    proc do_explore {} {
    global _gitworktree
    - set explorer [get_explorer]
    - eval exec $explorer [list [file nativename $_gitworktree]] &
    + set cmd [get_explorer]
    + lappend cmd [file nativename $_gitworktree]
    + safe_exec_bg $cmd
    }

    # Open file relative to the working tree by the default associated app.
    proc do_file_open {file} {
    global _gitworktree
    - set explorer [get_explorer]
    + set cmd [get_explorer]
    set full_file_path [file join $_gitworktree $file]
    - exec $explorer [file nativename $full_file_path] &
    + lappend cmd [file nativename $full_file_path]
    + safe_exec_bg $cmd
    }

    set is_quitting 0
    @@ -2316,7 +2341,7 @@
    if {![string match amend* $commit_type]
    && $msg ne {}} {
    catch {
    - set fd [open $save w]
    + set fd [safe_open_file $save w]
    fconfigure $fd -encoding utf-8
    puts -nonewline $fd $msg
    close $fd
    @@ -2760,17 +2785,16 @@

    if {[is_Windows]} {
    # Use /git-bash.exe if available
    - set normalized [file normalize $::argv0]
    - regsub "/mingw../libexec/git-core/git-gui$" \
    - $normalized "/git-bash.exe" cmdLine
    - if {$cmdLine != $normalized && [file exists $cmdLine]} {
    - set cmdLine [list "Git Bash" $cmdLine &]
    + set _git_bash [safe_exec [list cygpath -m /git-bash.exe]]
    + if {[file executable $_git_bash]} {
    + set _bash_cmdline [list "Git Bash" $_git_bash]
    } else {
    - set cmdLine [list "Git Bash" bash --login -l &]
    + set _bash_cmdline [list "Git Bash" bash --login -l]
    }
    .mbar.repository add command \
    -label [mc "Git Bash"] \
    - -command {eval exec [auto_execok start] $cmdLine}
    + -command {safe_exec_bg [concat [list [_which cmd] /c start] $_bash_cmdline]}
    + unset _git_bash
    }

    if {[is_Windows] || ![is_bare]} {
    @@ -4079,7 +4103,7 @@
    }
    } elseif {$m} {
    catch {
    - set fd [open [gitdir GITGUI_BCK] w]
    + set fd [safe_open_file [gitdir GITGUI_BCK] w]
    fconfigure $fd -encoding utf-8
    puts -nonewline $fd $msg
    close $fd
    diff -Nru git-2.50.0/git-gui/lib/blame.tcl git-2.50.1/git-gui/lib/blame.tcl
    --- git-2.50.0/git-gui/lib/blame.tcl 2025-06-16 08:42:57.000000000 +0300
    +++ git-2.50.1/git-gui/lib/blame.tcl 2025-06-16 08:11:33.000000000 +0300
    @@ -481,14 +481,14 @@
    if {$do_textconv ne 0} {
    set fd [open_cmd_pipe $textconv $path]
    } else {
    - set fd [open $path r]
    + set fd [safe_open_file $path r]
    }
    fconfigure $fd -eofchar {}
    } else {
    if {$do_textconv ne 0} {
    - set fd [git_read cat-file --textconv "$commit:$path"]
    + set fd [git_read [list cat-file --textconv "$commit:$path"]]
    } else {
    - set fd [git_read cat-file blob "$commit:$path"]
    + set fd [git_read [list cat-file blob "$commit:$path"]]
    }
    }
    fconfigure $fd \
    @@ -617,7 +617,7 @@
    }

    lappend options -- $path
    - set fd [eval git_read --nice blame $options]
    + set fd [git_read_nice [concat blame $options]]
    fconfigure $fd -blocking 0 -translation lf -encoding utf-8
    fileevent $fd readable [cb _read_blame $fd $cur_w $cur_d]
    set current_fd $fd
    @@ -986,7 +986,7 @@
    if {[catch {set msg