)]}'
{
  "commit": "bbbfe4af4fb5bc246a6cb15e95f29a3cd05e9145",
  "tree": "1e91e2b05f128b6179909e13da8ebca7199ecc4a",
  "parents": [
    "1d1df7539771d00721abe5dd8da4645e233ed3f5"
  ],
  "author": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Wed Feb 21 16:03:17 2024 +0000"
  },
  "committer": {
    "name": "Andrew Burgess",
    "email": "aburgess@redhat.com",
    "time": "Sat Sep 07 20:28:58 2024 +0100"
  },
  "message": "gdb: simplify completion_result::print_matches\n\nSimplify completion_result::print_matches by removing one of the code\npaths.  Now, every time we call ::print_matches we always add the\ntrailing quote.\n\nPreviously, when using the \u0027complete\u0027 command, if there was only one\nresult then trailing quote was added in ::build_completion_result, but\nwhen we had multiple results the trailing quote was added in\n::print_matches.  As a consequence, ::print_matches had to understand\nnot to add the trailing quote for the single result case.\n\nAfter this commit we don\u0027t add the trailing quote in\n::build_completion_result, instead ::print_matches always adds the\ntrailing quote, which makes ::print_matches simpler.\n\nHowever, there is a slight problem.  When completion is being driven\nby readline, and not by the \u0027complete\u0027 command, we still need to\nmanually add the trailing quote in the single result case, and as the\nprinting is done by readline we can\u0027t add the quote at the time of\nprinting, and so, in ::build_completion_result, we still add the\ntrailing quote, but only when completion is being done for readline.\n\nAnd this does cause a small problem.  When completing a filename, if\nthe completion results in a directory name then, when using the\n\u0027complete\u0027 command, GDB should not be adding a trailing quote.  For\nexample, if we have the file /tmp/xxx/foo.c, then what we should see\nis this:\n\n  (gdb) complete file \u0027/tmp/xx\n  file \u0027tmp/xxx/\n\nBut what we actually see after this commit is this:\n\n  (gdb) complete file \u0027/tmp/xx\n  file \u0027tmp/xxx/\u0027\n\nPreviously we didn\u0027t get the trailing quote in this case, as when\nthere is only a single result, the quote was added in\n::build_completion_result, and for filename completion, GDB didn\u0027t\nknow what the quote character was in ::build_completion_result, so no\nquote was added.  Now that the trailing quote is always added in\n::print_matches, and GDB does know the quote character at this point,\nso we are now getting the trailing quote, which is not correct.\n\nThis is a regression, but really, GDB is now broken in a consistent\nway, if we create the file /tmp/xxa/bar.c, then previously if we did\nthis:\n\n  (gdb) complete file \u0027/tmp/xx\n  file \u0027/tmp/xxa/\u0027\n  file \u0027/tmp/xxx/\u0027\n\nNotice how we get the trailing quote in this case, this is the before\npatch behaviour, and is also wrong.\n\nA later commit will fix things so that the trailing quote is not added\nin this filename completion case, but for now I\u0027m going to accept this\nsmall regression.\n\nThis change in behaviour caused some failures in one of the completion\ntests, I\u0027ve tweaked the test case to expect the trailing quote as part\nof this commit, but will revert this in a later commit in this series.\n\nI\u0027ve also added an extra test for when the \u0027complete\u0027 command does\ncomplete to a single complete filename, in which case the trailing\nquote is expected.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "370a57e6d7fd9387f124e2b3d0a544049d01ac3d",
      "old_mode": 33188,
      "old_path": "gdb/completer.c",
      "new_id": "2793ce600b98002f4c63ff235ef95dd929b748bd",
      "new_mode": 33188,
      "new_path": "gdb/completer.c"
    },
    {
      "type": "modify",
      "old_id": "c670637ad61fbfc5132d5ec6a21018e0750e492c",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.base/filename-completion.exp",
      "new_id": "e8acd2f85cf0cd0cc273a2b066f97edf173f9bdc",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/filename-completion.exp"
    }
  ]
}
