isomorphic-git 1.44.13 → 1.44.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1764,7 +1764,16 @@ class GitIndexManager {
1764
1764
  if (unmergedPaths.length && !allowUnmerged)
1765
1765
  throw new UnmergedPathsError(unmergedPaths)
1766
1766
 
1767
- result = await closure(index);
1767
+ try {
1768
+ result = await closure(index);
1769
+ } catch (err) {
1770
+ // A failed closure may already have mutated the in-memory index. Drop
1771
+ // it so the next acquire reloads the unchanged index from disk, rather
1772
+ // than flushing a half-applied change that was never written.
1773
+ theIndexCache.map.delete(filepath);
1774
+ theIndexCache.stats.delete(filepath);
1775
+ throw err
1776
+ }
1768
1777
  if (index._dirty) {
1769
1778
  // Acquire a file lock while we're writing the index file
1770
1779
  // let fileLock = await Lock(filepath)
package/managers/index.js CHANGED
@@ -1758,7 +1758,16 @@ class GitIndexManager {
1758
1758
  if (unmergedPaths.length && !allowUnmerged)
1759
1759
  throw new UnmergedPathsError(unmergedPaths)
1760
1760
 
1761
- result = await closure(index);
1761
+ try {
1762
+ result = await closure(index);
1763
+ } catch (err) {
1764
+ // A failed closure may already have mutated the in-memory index. Drop
1765
+ // it so the next acquire reloads the unchanged index from disk, rather
1766
+ // than flushing a half-applied change that was never written.
1767
+ theIndexCache.map.delete(filepath);
1768
+ theIndexCache.stats.delete(filepath);
1769
+ throw err
1770
+ }
1762
1771
  if (index._dirty) {
1763
1772
  // Acquire a file lock while we're writing the index file
1764
1773
  // let fileLock = await Lock(filepath)