diff: stop output garbled message in dry run mode

Earlier, b55e6d36 (diff: ensure consistent diff behavior with
ignore options, 2025-08-08) introduced "dry-run" mode to the
diff machinery so that content-based diff filtering (like
ignoring space changes or those that match -I<regex>) can first
try to produce a patch without emitting any output to see if
under the given diff filtering condition we would get any output
lines, and a new helper function diff_flush_patch_quietly() was
introduced to use the mode to see an individual filepair needs
to be shown.

However, the solution was not complete. When files are deleted,
file modes change, or there are unmerged entries in the index,
dry-run mode still produces output because we overlooked these
conditions, and as a result, dry-run mode was not quiet.

To fix this, return early in emit_diff_symbol_from_struct() if
we are in dry-run mode. This function will be called by all the
emit functions to output the results. Returning early can avoid
diff output when files are deleted or file modes are changed.
Stop print message in dry-run mode if we have unmerged entries
in index. Discard output of external diff tool in dry-run mode.

Signed-off-by: Lidong Yan <yldhome2d2@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 files changed
tree: 384e5b578005f7224eecdbf1cca5e4a241ce0979
  1. .github/
  2. bin-wrappers/
  3. block-sha1/
  4. builtin/
  5. ci/
  6. compat/
  7. compiler-tricks/
  8. contrib/
  9. Documentation/
  10. ewah/
  11. git-gui/
  12. gitk-git/
  13. gitweb/
  14. mergetools/
  15. negotiator/
  16. oss-fuzz/
  17. perl/
  18. po/
  19. refs/
  20. reftable/
  21. sha1/
  22. sha1dc/
  23. sha256/
  24. src/
  25. subprojects/
  26. t/
  27. templates/
  28. trace2/
  29. xdiff/
  30. .cirrus.yml
  31. .clang-format
  32. .editorconfig
  33. .gitattributes
  34. .gitignore
  35. .gitlab-ci.yml
  36. .gitmodules
  37. .mailmap
  38. .tsan-suppressions
  39. abspath.c
  40. abspath.h
  41. aclocal.m4
  42. add-interactive.c
  43. add-interactive.h
  44. add-patch.c
  45. advice.c
  46. advice.h
  47. alias.c
  48. alias.h
  49. alloc.c
  50. alloc.h
  51. apply.c
  52. apply.h
  53. archive-tar.c
  54. archive-zip.c
  55. archive.c
  56. archive.h
  57. attr.c
  58. attr.h
  59. banned.h
  60. base85.c
  61. base85.h
  62. bisect.c
  63. bisect.h
  64. blame.c
  65. blame.h
  66. blob.c
  67. blob.h
  68. bloom.c
  69. bloom.h
  70. branch.c
  71. branch.h
  72. builtin.h
  73. bundle-uri.c
  74. bundle-uri.h
  75. bundle.c
  76. bundle.h
  77. cache-tree.c
  78. cache-tree.h
  79. Cargo.toml
  80. cbtree.c
  81. cbtree.h
  82. chdir-notify.c
  83. chdir-notify.h
  84. check-builtins.sh
  85. checkout.c
  86. checkout.h
  87. chunk-format.c
  88. chunk-format.h
  89. CODE_OF_CONDUCT.md
  90. color.c
  91. color.h
  92. column.c
  93. column.h
  94. combine-diff.c
  95. command-list.txt
  96. commit-graph.c
  97. commit-graph.h
  98. commit-reach.c
  99. commit-reach.h
  100. commit-slab-decl.h
  101. commit-slab-impl.h
  102. commit-slab.h
  103. commit.c
  104. commit.h
  105. common-exit.c
  106. common-init.c
  107. common-init.h
  108. common-main.c
  109. config.c
  110. config.h
  111. config.mak.dev
  112. config.mak.in
  113. config.mak.uname
  114. configure.ac
  115. connect.c
  116. connect.h
  117. connected.c
  118. connected.h
  119. convert.c
  120. convert.h
  121. copy.c
  122. copy.h
  123. COPYING
  124. credential.c
  125. credential.h
  126. csum-file.c
  127. csum-file.h
  128. ctype.c
  129. daemon.c
  130. date.c
  131. date.h
  132. decorate.c
  133. decorate.h
  134. delta-islands.c
  135. delta-islands.h
  136. delta.h
  137. detect-compiler
  138. diagnose.c
  139. diagnose.h
  140. diff-delta.c
  141. diff-lib.c
  142. diff-merges.c
  143. diff-merges.h
  144. diff-no-index.c
  145. diff.c
  146. diff.h
  147. diffcore-break.c
  148. diffcore-delta.c
  149. diffcore-order.c
  150. diffcore-pickaxe.c
  151. diffcore-rename.c
  152. diffcore-rotate.c
  153. diffcore.h
  154. dir-iterator.c
  155. dir-iterator.h
  156. dir.c
  157. dir.h
  158. editor.c
  159. editor.h
  160. entry.c
  161. entry.h
  162. environment.c
  163. environment.h
  164. exec-cmd.c
  165. exec-cmd.h
  166. fetch-negotiator.c
  167. fetch-negotiator.h
  168. fetch-pack.c
  169. fetch-pack.h
  170. fmt-merge-msg.c
  171. fmt-merge-msg.h
  172. for-each-ref.h
  173. fsck.c
  174. fsck.h
  175. fsmonitor--daemon.h
  176. fsmonitor-ipc.c
  177. fsmonitor-ipc.h
  178. fsmonitor-ll.h
  179. fsmonitor-path-utils.h
  180. fsmonitor-settings.c
  181. fsmonitor-settings.h
  182. fsmonitor.c
  183. fsmonitor.h
  184. generate-cmdlist.sh
  185. generate-configlist.sh
  186. generate-hooklist.sh
  187. generate-perl.sh
  188. generate-python.sh
  189. generate-script.sh
  190. gettext.c
  191. gettext.h
  192. git-archimport.perl
  193. GIT-BUILD-OPTIONS.in
  194. git-compat-util.h
  195. git-curl-compat.h
  196. git-cvsexportcommit.perl
  197. git-cvsimport.perl
  198. git-cvsserver.perl
  199. git-difftool--helper.sh
  200. git-filter-branch.sh
  201. git-instaweb.sh
  202. git-merge-octopus.sh
  203. git-merge-one-file.sh
  204. git-merge-resolve.sh
  205. git-mergetool--lib.sh
  206. git-mergetool.sh
  207. git-p4.py
  208. git-quiltimport.sh
  209. git-request-pull.sh
  210. git-send-email.perl
  211. git-sh-i18n.sh
  212. git-sh-setup.sh
  213. git-submodule.sh
  214. git-svn.perl
  215. GIT-VERSION-FILE.in
  216. GIT-VERSION-GEN
  217. git-web--browse.sh
  218. git-zlib.c
  219. git-zlib.h
  220. git.c
  221. git.rc.in
  222. gpg-interface.c
  223. gpg-interface.h
  224. graph.c
  225. graph.h
  226. grep.c
  227. grep.h
  228. hash-lookup.c
  229. hash-lookup.h
  230. hash.c
  231. hash.h
  232. hashmap.c
  233. hashmap.h
  234. help.c
  235. help.h
  236. hex-ll.c
  237. hex-ll.h
  238. hex.c
  239. hex.h
  240. hook.c
  241. hook.h
  242. http-backend.c
  243. http-fetch.c
  244. http-push.c
  245. http-walker.c
  246. http.c
  247. http.h
  248. ident.c
  249. ident.h
  250. imap-send.c
  251. INSTALL
  252. iterator.h
  253. json-writer.c
  254. json-writer.h
  255. khash.h
  256. kwset.c
  257. kwset.h
  258. levenshtein.c
  259. levenshtein.h
  260. LGPL-2.1
  261. line-log.c
  262. line-log.h
  263. line-range.c
  264. line-range.h
  265. linear-assignment.c
  266. linear-assignment.h
  267. list-objects-filter-options.c
  268. list-objects-filter-options.h
  269. list-objects-filter.c
  270. list-objects-filter.h
  271. list-objects.c
  272. list-objects.h
  273. list.h
  274. lockfile.c
  275. lockfile.h
  276. log-tree.c
  277. log-tree.h
  278. loose.c
  279. loose.h
  280. ls-refs.c
  281. ls-refs.h
  282. mailinfo.c
  283. mailinfo.h
  284. mailmap.c
  285. mailmap.h
  286. Makefile
  287. match-trees.c
  288. match-trees.h
  289. mem-pool.c
  290. mem-pool.h
  291. merge-blobs.c
  292. merge-blobs.h
  293. merge-ll.c
  294. merge-ll.h
  295. merge-ort-wrappers.c
  296. merge-ort-wrappers.h
  297. merge-ort.c
  298. merge-ort.h
  299. merge.c
  300. merge.h
  301. mergesort.h
  302. meson.build
  303. meson_options.txt
  304. midx-write.c
  305. midx.c
  306. midx.h
  307. name-hash.c
  308. name-hash.h
  309. notes-cache.c
  310. notes-cache.h
  311. notes-merge.c
  312. notes-merge.h
  313. notes-utils.c
  314. notes-utils.h
  315. notes.c
  316. notes.h
  317. object-file-convert.c
  318. object-file-convert.h
  319. object-file.c
  320. object-file.h
  321. object-name.c
  322. object-name.h
  323. object.c
  324. object.h
  325. odb.c
  326. odb.h
  327. oid-array.c
  328. oid-array.h
  329. oidmap.c
  330. oidmap.h
  331. oidset.c
  332. oidset.h
  333. oidtree.c
  334. oidtree.h
  335. pack-bitmap-write.c
  336. pack-bitmap.c
  337. pack-bitmap.h
  338. pack-check.c
  339. pack-mtimes.c
  340. pack-mtimes.h
  341. pack-objects.c
  342. pack-objects.h
  343. pack-refs.c
  344. pack-refs.h
  345. pack-revindex.c
  346. pack-revindex.h
  347. pack-write.c
  348. pack.h
  349. packfile.c
  350. packfile.h
  351. pager.c
  352. pager.h
  353. parallel-checkout.c
  354. parallel-checkout.h
  355. parse-options-cb.c
  356. parse-options.c
  357. parse-options.h
  358. parse.c
  359. parse.h
  360. patch-delta.c
  361. patch-ids.c
  362. patch-ids.h
  363. path-walk.c
  364. path-walk.h
  365. path.c
  366. path.h
  367. pathspec.c
  368. pathspec.h
  369. pkt-line.c
  370. pkt-line.h
  371. preload-index.c
  372. preload-index.h
  373. pretty.c
  374. pretty.h
  375. prio-queue.c
  376. prio-queue.h
  377. progress.c
  378. progress.h
  379. promisor-remote.c
  380. promisor-remote.h
  381. prompt.c
  382. prompt.h
  383. protocol-caps.c
  384. protocol-caps.h
  385. protocol.c
  386. protocol.h
  387. prune-packed.c
  388. prune-packed.h
  389. pseudo-merge.c
  390. pseudo-merge.h
  391. quote.c
  392. quote.h
  393. range-diff.c
  394. range-diff.h
  395. reachable.c
  396. reachable.h
  397. read-cache-ll.h
  398. read-cache.c
  399. read-cache.h
  400. README.md
  401. rebase-interactive.c
  402. rebase-interactive.h
  403. rebase.c
  404. rebase.h
  405. ref-filter.c
  406. ref-filter.h
  407. reflog-walk.c
  408. reflog-walk.h
  409. reflog.c
  410. reflog.h
  411. refs.c
  412. refs.h
  413. refspec.c
  414. refspec.h
  415. remote-curl.c
  416. remote.c
  417. remote.h
  418. replace-object.c
  419. replace-object.h
  420. repo-settings.c
  421. repo-settings.h
  422. repository.c
  423. repository.h
  424. rerere.c
  425. rerere.h
  426. reset.c
  427. reset.h
  428. resolve-undo.c
  429. resolve-undo.h
  430. revision.c
  431. revision.h
  432. run-command.c
  433. run-command.h
  434. sane-ctype.h
  435. scalar.c
  436. SECURITY.md
  437. send-pack.c
  438. send-pack.h
  439. sequencer.c
  440. sequencer.h
  441. serve.c
  442. serve.h
  443. server-info.c
  444. server-info.h
  445. setup.c
  446. setup.h
  447. sh-i18n--envsubst.c
  448. sha1dc_git.c
  449. sha1dc_git.h
  450. shallow.c
  451. shallow.h
  452. shared.mak
  453. shell.c
  454. shortlog.h
  455. sideband.c
  456. sideband.h
  457. sigchain.c
  458. sigchain.h
  459. simple-ipc.h
  460. sparse-index.c
  461. sparse-index.h
  462. split-index.c
  463. split-index.h
  464. stable-qsort.c
  465. statinfo.c
  466. statinfo.h
  467. strbuf.c
  468. strbuf.h
  469. streaming.c
  470. streaming.h
  471. string-list.c
  472. string-list.h
  473. strmap.c
  474. strmap.h
  475. strvec.c
  476. strvec.h
  477. sub-process.c
  478. sub-process.h
  479. submodule-config.c
  480. submodule-config.h
  481. submodule.c
  482. submodule.h
  483. symlinks.c
  484. symlinks.h
  485. tag.c
  486. tag.h
  487. tar.h
  488. tempfile.c
  489. tempfile.h
  490. thread-utils.c
  491. thread-utils.h
  492. tmp-objdir.c
  493. tmp-objdir.h
  494. trace.c
  495. trace.h
  496. trace2.c
  497. trace2.h
  498. trailer.c
  499. trailer.h
  500. transport-helper.c
  501. transport-internal.h
  502. transport.c
  503. transport.h
  504. tree-diff.c
  505. tree-walk.c
  506. tree-walk.h
  507. tree.c
  508. tree.h
  509. unicode-width.h
  510. unimplemented.sh
  511. unix-socket.c
  512. unix-socket.h
  513. unix-stream-server.c
  514. unix-stream-server.h
  515. unpack-trees.c
  516. unpack-trees.h
  517. upload-pack.c
  518. upload-pack.h
  519. url.c
  520. url.h
  521. urlmatch.c
  522. urlmatch.h
  523. usage.c
  524. userdiff.c
  525. userdiff.h
  526. utf8.c
  527. utf8.h
  528. varint.c
  529. varint.h
  530. version-def.h.in
  531. version.c
  532. version.h
  533. versioncmp.c
  534. versioncmp.h
  535. walker.c
  536. walker.h
  537. wildmatch.c
  538. wildmatch.h
  539. worktree.c
  540. worktree.h
  541. wrapper.c
  542. wrapper.h
  543. write-or-die.c
  544. write-or-die.h
  545. ws.c
  546. ws.h
  547. wt-status.c
  548. wt-status.h
  549. xdiff-interface.c
  550. xdiff-interface.h
README.md

Build status

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.adoc to get started, then see Documentation/giteveryday.adoc for a useful minimum set of commands, and Documentation/git-<commandname>.adoc for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.adoc (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission and Documentation/CodingGuidelines).

Those wishing to help with error message, usage and informational message string translations (localization l10) should see po/README.md (a po file is a Portable Object file that holds the translations).

To subscribe to the list, send an email to git+subscribe@vger.kernel.org (see https://subspace.kernel.org/subscribing.html for details). The mailing list archives are available at https://lore.kernel.org/git/, https://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks